/*
package com.akk.module.hxt.utils;

import com.alibaba.fastjson.JSON;
import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.*;


*/
/**
 * Created by zhangh on 2017/7/2 0002.
 *//*

public class QPayAPITestController {

    String md5Key = "05EC05E4080C46E7BCA215B72E5F9711";

    //开卡
    @Test
    public void TestOpenCardAPI() {
        Map reqMap = new HashMap();
        String timeStr = getTime();

        reqMap.put("version", "1.0.1");
        reqMap.put("agentId", "100602");
        reqMap.put("merId", "100110258141729");
        reqMap.put("frontUrl", "http://www.baidu.com");
        reqMap.put("backUrl", "http://www.baidu.com");
        reqMap.put("orderId", System.currentTimeMillis() + "");
        reqMap.put("txnTime", timeStr);
        //cardNo
        reqMap.put("cardNo", "6228480018197422977");
        //2 进行排序
        Map<String, Object> sPara = paraFilter(reqMap);
        //拼接报文
        String prestr = createLinkString(sPara);
        prestr += "&key=" + md5Key;
        System.out.println("待签名字符串: " + prestr);
        String str = MD5Util.MD5Encode(prestr, "UTF-8");
        System.out.println(str.toUpperCase());
        reqMap.put("sign", str.toUpperCase());
        String reqBody = JSON.toJSONString(reqMap);
        System.out.println(reqBody);
        String url = "http://localhost:9292/qpay/openCardApi.app";
        try {
            HttpResponse result = HttpClientHelper.doHttp(url, HttpClientHelper.POST, "utf-8", reqBody,
                    "60000", "text/plain;charset=UTF-8");
            System.out.println("返回结果=====>>" + result.getRspStr());

        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    //开卡查询
    @Test
    public void TestOpenCardQueryAPI() {
*/
/*        Map reqMap = new HashMap();
        String timeStr = getTime();
        reqMap.put("version", "1.0.1");
        reqMap.put("agentId", "100602");
        reqMap.put("merId", "100110258141729");
        reqMap.put("orderId", "1499329534169");
        reqMap.put("txnTime", "20170706162534");
        //2 进行排序
        Map<String, Object> sPara = paraFilter(reqMap);
        //拼接报文
        String prestr = createLinkString(sPara);
        prestr += "&key=" + md5Key;
        System.out.println("待签名字符串: " + prestr);
        String str = MD5Util.MD5Encode(prestr, "UTF-8");
        System.out.println(str.toUpperCase());
        reqMap.put("sign", str.toUpperCase());
        String reqBody = JSON.toJSONString(reqMap);
        System.out.println(reqBody);
        String url = "http://s18526m685.51mypc.cn:19640/qpay/openCardQueryApi.app";
        try {
            HttpResponse result = HttpClientHelper.doHttp(url, HttpClientHelper.POST, "utf-8", reqBody,
                    "60000", "text/plain;charset=UTF-8");
            System.out.println("返回结果=====>>" + result.getRspStr());

        } catch (Exception e) {
            e.printStackTrace();
        }*//*

    }

    //发送短信
    @Test
    public void TestConsumeSMSAPI() {
        Map reqMap = new HashMap();
        String timeStr = getTime();
        reqMap.put("version", "1.0.1");
        reqMap.put("agentId", "100602");
        reqMap.put("merId", "100110258141729");
        reqMap.put("orderId", System.currentTimeMillis() + "");
        reqMap.put("txnTime", timeStr);
        reqMap.put("txnAmt", "100");
        reqMap.put("realName", "张张");
        reqMap.put("identityCard", "130521199910071033");
        reqMap.put("cardNo", "6228480018197422977");//结算卡号
        reqMap.put("phoneNo", "18612779818");
        reqMap.put("token", "6235240000303640466");
        System.out.println(reqMap.get("orderId"));
        System.out.println(reqMap.get("txnTime"));
        //2 进行排序
        Map<String, Object> sPara = paraFilter(reqMap);
        //拼接报文
        String prestr = createLinkString(sPara);
        prestr += "&key=" + md5Key;
        System.out.println("待签名字符串: " + prestr);
        String str = MD5Util.MD5Encode(prestr, "UTF-8");
        System.out.println(str.toUpperCase());
        reqMap.put("sign", str.toUpperCase());
        String reqBody = JSON.toJSONString(reqMap);
        System.out.println(reqBody);
        String url = "http://localhost:9292/qpay/QpayConsumeSMSApi.app";
        try {
            HttpResponse result = HttpClientHelper.doHttp(url, HttpClientHelper.POST, "utf-8", reqBody,
                    "60000", "text/plain;charset=UTF-8");
            System.out.println("返回结果=====>>" + result.getRspStr());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void TestConsumeAPI() {
        Map reqMap = new HashMap();
        String timeStr = getTime();
        reqMap.put("version", "1.0.1");
        reqMap.put("agentId", "100602");
        reqMap.put("merId", "100110258141729");
        reqMap.put("backUrl", "http://122ceshi.com");
        reqMap.put("orderId", "1499333522740");
        reqMap.put("txnTime", "20170706173202");
        reqMap.put("txnAmt", "100");
        reqMap.put("token", "6235240000303640466");
        reqMap.put("smsCode", "767448");
        reqMap.put("settleAmt", "50");
		reqMap.put("settleCycle","0");
        //2 进行排序
        Map<String, Object> sPara = paraFilter(reqMap);
        //拼接报文
        String prestr = createLinkString(sPara);
        prestr += "&key=" + md5Key;
        System.out.println("待签名字符串: " + prestr);
        String str = MD5Util.MD5Encode(prestr, "UTF-8");
        System.out.println(str.toUpperCase());
        reqMap.put("sign", str.toUpperCase());
        String reqBody = JSON.toJSONString(reqMap);
        System.out.println(reqBody);
        String url = "http://s18526m685.51mypc.cn:19640/qpay/QpayConsumeApi.app";
        try {
            HttpResponse result = HttpClientHelper.doHttp(url, HttpClientHelper.POST, "utf-8", reqBody,
                    "60000", "text/plain;charset=UTF-8");
            System.out.println("返回结果=====>>" + result.getRspStr());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 //消费查询接口
    @Test
    public void TestConsumeQueryAPI() {
        //快捷订单查询
        Map reqMap = new HashMap();
        String timeStr = getTime();
        reqMap.put("version", "1.0.1");
        reqMap.put("agentId", "100602");
        reqMap.put("merId", "100110258141729"); //商户号
        reqMap.put("orderId", "1499328068828"); //原交易订单号
        reqMap.put("txnTime", "20170706160108"); //原交易时间
        //2 进行排序
        Map<String, Object> sPara = paraFilter(reqMap);
        //拼接报文
        String prestr = createLinkString(sPara);
        prestr += "&key=" + md5Key;
        System.out.println("待签名字符串: " + prestr);
        String str = MD5Util.MD5Encode(prestr, "UTF-8");
        System.out.println(str.toUpperCase());
        reqMap.put("sign", str.toUpperCase());
        String reqBody = JSON.toJSONString(reqMap);
        System.out.println(reqBody);
        String url = "http://localhost:9292/qpay/QpayConsumeQueryApi.app";
        try {
            HttpResponse result = HttpClientHelper.doHttp(url, HttpClientHelper.POST, "utf-8", reqBody,
                    "60000", "text/plain;charset=UTF-8");
            System.out.println("返回结果=====>>" + result.getRspStr());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    //提款订单查询
    @Test
    public void TestQpayWithdrawQueryApi() {

        Map reqMap = new HashMap();
        String timeStr = getTime();
        reqMap.put("version", "1.0.1");
        reqMap.put("agentId", "100602");
        reqMap.put("merId", "100110258141729");
        reqMap.put("orderId", "1502832416511"); //原交易订单号
        reqMap.put("txnTime", "20170816052656"); //原交易时间
        //2 进行排序
        Map<String, Object> sPara = paraFilter(reqMap);
        //拼接报文
        String prestr = createLinkString(sPara);
        prestr += "&key=" + md5Key;
        System.out.println("待签名字符串: " + prestr);
        String str = MD5Util.MD5Encode(prestr, "UTF-8");
        System.out.println(str.toUpperCase());
        reqMap.put("sign", str.toUpperCase());
        String reqBody = JSON.toJSONString(reqMap);
        System.out.println(reqBody);
        String url = "http://123.127.76.30:9080/qpay/QpayWithdrawQueryApi.app"; //测试
        try {
            HttpResponse result = HttpClientHelper.doHttp(url, HttpClientHelper.POST, "utf-8", reqBody,
                    "60000", "text/plain;charset=UTF-8");
            System.out.println("返回结果=====>>" + result.getRspStr());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
*/
/*    private static Map<String, Object> paraFilter(Map<String, Object> sArray) {
        Map<String, Object> result = new HashMap<String, Object>();
        if (sArray == null || sArray.size() <= 0) {
            return result;
        }

        for (String key : sArray.keySet()) {
            Object value = sArray.get(key);
            if (value == null || value.equals("")) {
                continue;
            }
            result.put(key, value);
        }
        return result;
    }*//*


*/
/*    public static String createLinkString(Map<String, Object> params) {
        List<String> keys = new ArrayList<String>(params.keySet());
        Collections.sort(keys);
        String prestr = "";
        for (int i = 0; i < keys.size(); i++) {
            String key = keys.get(i);
            Object value = params.get(key);
            if (i == keys.size() - 1) {// 拼接时，不包括最后一个&字符
                prestr = prestr + key + "=" + value;
            } else {
                prestr = prestr + key + "=" + value + "&";
            }
        }
        return prestr;
    }*//*


    public String getTime() {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        return sdf.format(new Date());
    }

}
*/
